//重载 流 输入 输出运算符  cout<<   cin>>
//使其可以实现对复数 实部和虚部的同时输入和输出。
//重载 + 双目运算符，实现复数的相加求和。

#include <iostream>
using namespace std;

class complex
{
public:
    complex(int r = 0,int i = 0)
        :_r(r),_i(i){}
    
    void dis()
    {
        cout<<_r<<" "<<_i<<endl;
    }
    friend ostream& operator<<(ostream &os, complex &c);
    friend istream & operator>>(istream &is, complex &c);
    friend complex operator+(const complex &a, const complex &b);

private:
    int _r;  //实部
    int _i;  //虚部
};

ostream & operator<<(ostream &os, complex &c)
{
    os<<c._r<<","<<c._i<<endl;
    return os;
}

istream & operator>>(istream &is, complex &c)
{
    is>>c._r;
    is>>c._i;
    return is;
}
complex operator+(const complex &a, const complex &b)
{
    complex tmp;
    tmp._r = a._r + b._r;
    tmp._i = a._i + b._i;
    return tmp;
}

int main()
{
    complex c1,c2,c;
    // c1.dis();
    cin>>c1;
    cout<<c1<<endl;  //目的是 实现此类功能
    cin>>c2;
    cout<<c2<<endl;
    c = c1 + c2;
    cout<<c<<endl;
    return 0;
}